#include <iostream>
#include <fstream>
#include <string>

using namespace std;

unsigned int hash(const string& str, unsigned int& base) {
    unsigned int answ = 0;
    unsigned int tmpBase = 1;
    for (int i = str.length() - 1; i >= 0; --i) {
		answ += tmpBase * str[i];
        base = tmpBase;
		tmpBase += tmpBase << 5; // p = 33;
	}
	return answ;
}

int findString(const string& subString, const string& text) {
    unsigned int base, hashInText = hash(text.substr(0, subString.length()), base), hashSub = hash(subString, base), end = text.length() - subString.length();
    for (size_t i = 0; i < end + 1; ++i) {
        if (hashSub == hashInText && !subString.compare(text.substr(i, subString.length()))) {
                return i;
        }
        hashInText = (i != end) ? ((hashInText - text[i] * base) << 5) + (hashInText - text[i] * base) + text[i + subString.length()] : -1;
    }
    return -1;
}

int main()
{
    ifstream ifile("in.txt");
    string text;
    if (getline(ifile, text)) {
        string subString;
        while (getline(ifile, subString)) {
            if(!subString.empty())
                cout << findString(subString, text) << endl;
        }
    }
    ifile.close();
    return 0;
}